package com.ibm.test.consumer.rest;

public class MyBizJob {
	private boolean isStopping = false;// 实际中要DB中取停止信号
	private String status;

	public void runJob() {
		int i = 10;
		status = "DOING";
		// 每次循环检查是否有停止信号
		while (--i > 0) {
			System.out.println("running turn No." + (10 - i));
			if (isStopping) {
				status = "STOPPED";
				break;
			}
			try {
				Thread.sleep(30 * 1000l);
			} catch (InterruptedException e) {
				e.printStackTrace();
				status = "FAIL";
				break;
			}
		}
		status = "DONE";
		System.out.println("Job Done");
	}

	public void stopJob() {
		this.isStopping = true;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}
}
